<?php
/**
 * Created by PhpStorm.
 * User: ysw
 * Date: 2020/6/29
 * Time: 10:39
 */
namespace app\api\validate;

use think\Validate;

class CreateVoteValidate extends Validate
{
    protected $rule = [
        'title'     =>  'require|max:40',
        'deadline'  =>  'require|date',
        'vote_num'  =>  'require|number|integer|gt:0',
        'vote_open' => 'require|in:0,1',
        'ad_limit'  => 'require|in:0,1,2,3,4,5',
        'ad_last_num'  => 'require|in:0,1,2,3,4,5',

        'create_vote_describe_id' => 'require|number|integer|gt:0',
        'create_vote_id' => 'require|number|integer|gt:0',

        'share_address' => 'require'
    ];
    protected $message  =   [
        'title.require'      =>  '标题必须填写',
        'title.max'          =>  '标题最多不能超过40个字符',

        'deadline.require'   =>  '时间必须填写',
        'deadline.date'      =>  '时间格式不正确',

        'vote_num.require'   =>  '可投票数必须填写',
        'vote_num.number'    =>  '可投票数填写数字',
        'vote_num.integer'   =>  '可投票数填写整数',
        'vote_num.gt'        =>  '可投票数填写正数',

        'vote_open.require'  =>  '是否开启广告参数必须填写',
        'vote_open.in'       =>  '是否开启广告参数不正确',

        'ad_limit.require'   => '广告上限必须填写',
        'ad_limit.in'        => '广告上限参数不正确',

        'ad_last_num.require'=> '完播票数必须填写',
        'ad_last_num.in'     => '完播票数参数不正确',

        'create_vote_describe_id.require'   =>  '选项id必须填写',
        'create_vote_describe_id.number'    =>  '选项id填写数字',
        'create_vote_describe_id.integer'   =>  '选项id填写整数',
        'create_vote_describe_id.gt'        =>  '选项id填写正数',

        'create_vote_id.require'   =>  '投票id必须填写',
        'create_vote_id.number'    =>  '投票id填写数字',
        'create_vote_id.integer'   =>  '投票id填写整数',
        'create_vote_id.gt'        =>  '投票id填写正数',

        'share_address.require'  => '分享地址必须填写',




    ];
    protected $scene = [
        'createVote'   =>  ['title','deadline','vote_num','vote_open','ad_limit','ad_last_num'],
        'addUserVote'  =>  ['create_vote_describe_id','create_vote_id'],
        'videoNotify'  =>  ['create_vote_describe_id'],
        'shareNotify' => ['create_vote_describe_id','share_address'],
        'myDelVote' => ['create_vote_id'],
    ];
}